package com.example.understand_compose1.fet_retrofitusage.data.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update
import com.example.understand_compose1.fet_retrofitusage.data.room.User

@Dao
interface UserDao {
    @get:Query("SELECT * FROM user")
    val all: List<User?>?

    @Query("SELECT * FROM user WHERE uid=:id")
    fun getUser(id: Int): User?

    @Query(
        "SELECT * FROM user WHERE first_name LIKE :first AND " +
                "last_name LIKE :last LIMIT 1"
    )
    fun findByName(first: String?, last: String?): User?

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insertAll(vararg users: User?)

    @Delete
    fun delete(user: User?)

    @Update
    fun update(vararg users: User?): Int
}